﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:uc="clr-namespace:FileExplorer.WPF.UserControls"
    xmlns:bc="clr-namespace:FileExplorer.WPF.BaseControls"
    xmlns:def="clr-namespace:FileExplorer.WPF.Defines"
    xmlns:anim="clr-namespace:FileExplorer.WPF.Animations"
     xmlns:hub="http://www.quickzip.org/UIEventHub"               
    >
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/FileExplorer3.WPF;component/Themes/Default/Colors.xaml" />
        <ResourceDictionary Source="pack://application:,,,/FileExplorer3.WPF;component/Themes/Default/Brushes.xaml" />
        <ResourceDictionary Source="pack://application:,,,/FileExplorer3.WPF;component/Themes/Default/Geometry.xaml" />
        <ResourceDictionary Source="pack://application:,,,/FileExplorer3.WPF;component/Themes/Common/Buttons.xaml" />
        <ResourceDictionary Source="pack://application:,,,/FileExplorer3.WPF;component/Themes/Common/DropDown.xaml" />
    </ResourceDictionary.MergedDictionaries>



    <ControlTemplate x:Key="treeViewItemTemplate" TargetType="{x:Type uc:TreeViewItemEx}">
        <Grid HorizontalAlignment="Stretch" x:Name="baseGrid" >
            <Grid.ColumnDefinitions>
                <ColumnDefinition MinWidth="19" Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition/>
            </Grid.RowDefinitions>

            <bc:HotTrack Grid.Column="1" Grid.Row="0"  Grid.ColumnSpan="2" 
                         IsDragging="{Binding (hub:UIEventHubProperties.IsSelecting), RelativeSource={RelativeSource TemplatedParent} }"
                         IsDraggingOver="{Binding (hub:UIEventHubProperties.IsDraggingOver), RelativeSource={RelativeSource TemplatedParent} }"                    
                         IsSelected="{TemplateBinding IsSelected}" FillFullRow="True">
                <StackPanel Orientation="Horizontal">
                    <ContentPresenter x:Name="PART_Header" HorizontalAlignment="Stretch"  
                                  Grid.Column="1" Grid.Row="0"  Grid.ColumnSpan="2"
                                  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" ContentSource="Header" 
                                  Margin="{TemplateBinding BorderThickness}"/>

                    <!--<anim:SilverLightMain Grid.Column="4" Visibility="{Binding IsLoading, 
                            Converter={StaticResource btvc},
                            RelativeSource={RelativeSource TemplatedParent}}" />-->
                </StackPanel>
            </bc:HotTrack>

            <ToggleButton x:Name="Expander" ClickMode="Press" DataContext="{x:Null}"
                          IsChecked="{Binding IsExpanded, RelativeSource={RelativeSource TemplatedParent}}" 
                          Style="{StaticResource ExpandCollapseToggleStyle}"/>



            <ItemsPresenter x:Name="ItemsHost" Grid.ColumnSpan="2" Grid.Column="1" Grid.Row="1"/>

        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsExpanded" Value="false">
                <Setter Property="Visibility" TargetName="ItemsHost" Value="Collapsed"/>
            </Trigger>
            <Trigger Property="HasItems" Value="false">
                <Setter Property="Visibility" TargetName="Expander" Value="Hidden"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="TreeViewItemFocusVisual">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Rectangle/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="TreeViewItemExStyle" TargetType="{x:Type uc:TreeViewItemEx}">
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="FocusVisualStyle" Value="{StaticResource TreeViewItemFocusVisual}"/>
        <Setter Property="Padding" Value="1,0,0,0"/>
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
        <Setter Property="Template" Value="{StaticResource treeViewItemTemplate}" />
        <Setter Property="VerticalContentAlignment" Value="Top" />
        <Setter Property="HorizontalContentAlignment" Value="Left" />
        <Style.Triggers>
            <!--This trigger is needed, because RelativeSource binding can only succeeds if the current MenuItem is already connected to its visual parent-->
            <!--<Trigger Property="IsVisible" Value="True">
                <Setter Property="HorizontalContentAlignment" Value="{Binding Path=HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
                <Setter Property="VerticalContentAlignment" Value="{Binding Path=VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
            </Trigger>-->

            <Trigger Property="VirtualizingStackPanel.IsVirtualizing" Value="true">
                <Setter Property="ItemsPanel">
                    <Setter.Value>
                        <ItemsPanelTemplate>
                            <VirtualizingStackPanel HorizontalAlignment="Stretch"/>
                        </ItemsPanelTemplate>
                    </Setter.Value>
                </Setter>
            </Trigger>
        </Style.Triggers>
    </Style>


</ResourceDictionary>